import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_admin/api/odoo/dynamic_data_api.dart';
import 'package:flutter_admin/api/odoo/sale_bid_project_odoo_api.dart';
import 'package:flutter_admin/models/odoo/sale_bid_project.dart';
import 'package:flutter_admin/pages/common/cry/cry_button.dart';
import 'package:flutter_admin/pages/common/cry/form/cry_input.dart';
import 'package:flutter_admin/pages/common/cry/form/cry_select.dart';
import 'package:flutter_admin/pages/common/cry/form/cry_select_date.dart';
import 'package:flutter_admin/pages/common/cry/form/index.dart';
import 'package:flutter_admin/pages/common/cry/model/response_body_api.dart';
import 'package:flutter_admin/pages/common/cry/utils/cry_utils.dart';
import 'package:flutter_admin/pages/common/cry/vo/select_option_vo.dart';
import 'package:flutter_admin/pages/odoo/sale_bid_project/sale_bid_project_form_select.dart';
import 'package:intl/intl.dart';
import 'package:quiver/strings.dart';
import '../../../generated/l10n.dart';

class SaleBidProjectEdit extends StatefulWidget {
  SaleBidProjectEdit({this.saleBidProject, this.isView = false});

  final SaleBidProject? saleBidProject;

  final bool isView;

  @override
  _SaleBidProjectEditState createState() => _SaleBidProjectEditState();
}

class _SaleBidProjectEditState extends State<SaleBidProjectEdit> {
  late SaleBidProject saleBidProject;
  bool? isAdd;

  final GlobalKey<FormState> formKey = GlobalKey<FormState>();

  List<SelectOptionVO> projectcategoryList = [];
  List<SelectOptionVO> projectnatureList = [];
  List<SelectOptionVO> bidcategoryList = [];
  List<SelectOptionVO> projectattributeList = [];
  List<SelectOptionVO> issecondbargainingList = [];
  List<SelectOptionVO> bidresultsList = [];

  DateFormat format = DateFormat('yyyy-MM-dd');

  @override
  void initState() {
    super.initState();
    this.isAdd = widget.saleBidProject == null;
    this.saleBidProject = widget.saleBidProject ?? SaleBidProject();
    if (widget.saleBidProject == null) {
      this.saleBidProject.buydeadline = null;
      this.saleBidProject.clarifydeadline = null;
      this.saleBidProject.biddeadline = null;
      this.saleBidProject.openingdate = null;
      this.saleBidProject.publicitydate = null;
      this.saleBidProject.deliverydate = null;
    }
    _loadSelectVO();
  }

  _loadSelectVO() async {
    projectcategoryList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "市场部"),
      SelectOptionVO(value: '1', label: "海外部"),
      SelectOptionVO(value: '2', label: "其他"),
    ];
    projectnatureList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "省采"),
      SelectOptionVO(value: '1', label: "铁塔"),
      SelectOptionVO(value: '2', label: "电网"),
      SelectOptionVO(value: '3', label: "广电"),
      SelectOptionVO(value: '4', label: "政企"),
      SelectOptionVO(value: '5', label: "运营商"),
      SelectOptionVO(value: '6', label: "采集"),
    ];
    bidcategoryList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "供货标"),
      SelectOptionVO(value: '1', label: "总包标"),
    ];
    projectattributeList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "传统"),
      SelectOptionVO(value: '1', label: "创新"),
    ];
    issecondbargainingList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "无"),
      SelectOptionVO(value: '1', label: "有"),
    ];
    bidresultsList = [
      SelectOptionVO(value: '', label: ""),
      SelectOptionVO(value: '0', label: "未中标"),
      SelectOptionVO(value: '1', label: "中标"),
    ];
    if (saleBidProject.formId != null) {
      ResponseBodyApi res = await DynamicDataApi.getModels(
          model: "sale.inquiry.form",
          key: 'id',
          val: int.parse(saleBidProject.formId!));
      if (res.success!) {
        saleBidProject.formNo = res.data[0]["inquiry_no"].toString();
      }
    }
    setState(() {});
  }

  _selectForm() async {
    showDialog(
      context: context,
      builder: (BuildContext context) => Dialog(
        child: SaleBidProjectFormSelect(),
      ),
    ).then((v) {
      if (v != null) {
        saleBidProject.formId = v["id"].toString();
        saleBidProject.formNo = v["inquiry_no"].toString();
        setState(() {});
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    var form = Form(
      key: formKey,
      child: Wrap(
        children: <Widget>[
          Row(
            children: [
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '项目类别',
                        enable: false,
                        value: saleBidProject.projectcategory == '0'
                            ? '市场部'
                            : saleBidProject.projectcategory == '1'
                                ? '海外部'
                                : saleBidProject.projectcategory == '2'
                                    ? '其他'
                                    : "",
                      )
                    : CrySelect(
                        label: '*项目类别',
                        dataList: projectcategoryList,
                        value: saleBidProject.projectcategory,
                        onSaved: (v) => {saleBidProject.projectcategory = v},
                        validator: (v) {
                          return v!.isEmpty ? S.of(context).required : null;
                        },
                      ),
              ),
              Expanded(
                child: CryInput(
                  label: widget.isView ? '项目编号' : '*项目编号',
                  enable: !widget.isView,
                  value: saleBidProject.projectcode,
                  onSaved: (v) {
                    saleBidProject.projectcode = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: widget.isView ? '项目名称' : '*项目名称',
                  enable: !widget.isView,
                  value: saleBidProject.projectname,
                  onSaved: (v) {
                    saleBidProject.projectname = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: widget.isView ? '项目国别' : '*项目国别',
                  enable: !widget.isView,
                  value: saleBidProject.projectnation,
                  onSaved: (v) {
                    saleBidProject.projectnation = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: widget.isView ? '省份' : '*省份',
                  enable: !widget.isView,
                  value: saleBidProject.province,
                  onSaved: (v) {
                    saleBidProject.province = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              ),
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '项目性质',
                        enable: false,
                        value: saleBidProject.projectnature == '0'
                            ? '省采'
                            : saleBidProject.projectnature == '1'
                                ? '铁塔'
                                : saleBidProject.projectnature == '2'
                                    ? '电网'
                                    : saleBidProject.projectnature == '3'
                                        ? '广电'
                                        : saleBidProject.projectnature == '4'
                                            ? '政企'
                                            : saleBidProject.projectnature ==
                                                    '5'
                                                ? '运营商'
                                                : saleBidProject
                                                            .projectnature ==
                                                        '6'
                                                    ? '采集'
                                                    : "",
                      )
                    : CrySelect(
                        label: '*项目性质',
                        dataList: projectnatureList,
                        value: saleBidProject.projectnature,
                        onSaved: (v) => {saleBidProject.projectnature = v},
                        validator: (v) {
                          return v!.isEmpty ? S.of(context).required : null;
                        },
                      ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: widget.isView ? '客户名称' : '*客户名称',
                  enable: !widget.isView,
                  value: saleBidProject.customername,
                  onSaved: (v) {
                    saleBidProject.customername = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              ),
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '招标类别',
                        enable: false,
                        value: saleBidProject.bidcategory == '0'
                            ? '供货标'
                            : saleBidProject.bidcategory == '1'
                                ? '总包标'
                                : "",
                      )
                    : CrySelect(
                        label: '*招标类别',
                        dataList: bidcategoryList,
                        value: saleBidProject.bidcategory,
                        onSaved: (v) => {saleBidProject.bidcategory = v},
                        validator: (v) {
                          return v!.isEmpty ? S.of(context).required : null;
                        },
                      ),
              ),
              // 器件有班组
              // 箱体没有班组
              Expanded(
                child: CryInput(
                  label: widget.isView ? '招标代理名称' : '*招标代理名称',
                  enable: !widget.isView,
                  value: saleBidProject.bidagency,
                  onSaved: (v) {
                    saleBidProject.bidagency = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: widget.isView ? '产品名称' : '*产品名称',
                  enable: !widget.isView,
                  value: saleBidProject.productname,
                  onSaved: (v) {
                    saleBidProject.productname = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              ),
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '项目属性',
                        enable: false,
                        value: saleBidProject.projectattribute == '0'
                            ? '传统'
                            : saleBidProject.projectattribute == '1'
                                ? '创新'
                                : "",
                      )
                    : CrySelect(
                        label: '*项目属性',
                        dataList: projectattributeList,
                        value: saleBidProject.projectattribute,
                        onSaved: (v) => {saleBidProject.projectattribute = v},
                        validator: (v) {
                          return v!.isEmpty ? S.of(context).required : null;
                        },
                      ),
              ),
              //num
              Expanded(
                child: CryInput(
                  label: widget.isView ? '项目规模/产品数量' : '*项目规模/产品数量',
                  enable: !widget.isView,
                  value: saleBidProject.projectsize,
                  onSaved: (v) {
                    saleBidProject.projectsize = v;
                  },
                  validator: (v) {
                    return v!.isEmpty ? S.of(context).required : null;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              //num
              Expanded(
                child: CryInputNum(
                  label: widget.isView ? '项目预算(含税/万元)' : '*项目预算(含税/万元)',
                  enable: !widget.isView,
                  value: saleBidProject.projectbudget,
                  onSaved: (v) {
                    saleBidProject.projectbudget = v;
                  },
                  validator: (v) {
                    return v!.isEmpty
                        ? S.of(context).required
                        : v == '0'
                            ? '项目预算不能为0'
                            // : int.parse(v) > 100
                            //     ? '项目预算小于等于100'
                            : null;
                  },
                ),
              ),
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '购标截止时间',
                          enable: false,
                          value: saleBidProject.buydeadline,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '购标截止时间',
                                value: saleBidProject.buydeadline,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.buydeadline = v;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.buydeadline = v;
                                },
                              ),
                            ),
                            Expanded(
                                flex: 2,
                                child: CryButton(
                                  label: '清除',
                                  onPressed: () {
                                    saleBidProject.buydeadline = null;
                                    setState(() {});
                                  },
                                  iconData: Icons.cancel,
                                ))
                          ],
                        )),
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '澄清截止时间',
                          enable: false,
                          value: saleBidProject.clarifydeadline,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '澄清截止时间',
                                value: saleBidProject.clarifydeadline,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.clarifydeadline = v;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.clarifydeadline = v;
                                },
                              ),
                            ),
                            Expanded(
                                flex: 2,
                                child: CryButton(
                                  label: '清除',
                                  onPressed: () {
                                    saleBidProject.clarifydeadline = null;
                                    setState(() {});
                                  },
                                  iconData: Icons.cancel,
                                ))
                          ],
                        ))
            ],
          ),
          Row(
            children: [
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '投标截止时间',
                          enable: false,
                          value: saleBidProject.biddeadline,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '投标截止时间',
                                value: saleBidProject.biddeadline,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.biddeadline = v;
                                  var tou = DateTime.parse(
                                      saleBidProject.biddeadline!);
                                  var kai = DateTime.parse(
                                      saleBidProject.openingdate!);
                                  saleBidProject.openingdate = tou.isBefore(kai)
                                      ? saleBidProject.openingdate
                                      : saleBidProject.biddeadline;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.biddeadline = v;
                                },
                              ),
                            ),
                            Expanded(
                                flex: 2,
                                child: CryButton(
                                  label: '清除',
                                  onPressed: () {
                                    saleBidProject.biddeadline = null;
                                    setState(() {});
                                  },
                                  iconData: Icons.cancel,
                                ))
                          ],
                        )),
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '开标日期',
                          enable: false,
                          value: saleBidProject.openingdate,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '开标日期',
                                value: saleBidProject.openingdate,
                                firstDate:
                                    isNotBlank(saleBidProject.biddeadline)
                                        ? format
                                            .parse(saleBidProject.biddeadline!)
                                        : null,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.openingdate = v;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.openingdate = v;
                                },
                              ),
                            ),
                            Expanded(
                                flex: 2,
                                child: CryButton(
                                  label: '清除',
                                  onPressed: () {
                                    saleBidProject.openingdate = null;
                                    setState(() {});
                                  },
                                  iconData: Icons.cancel,
                                ))
                          ],
                        )),
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '公示日期',
                          enable: false,
                          value: saleBidProject.publicitydate,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '公示日期',
                                value: saleBidProject.publicitydate,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.publicitydate = v;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.publicitydate = v;
                                },
                              ),
                            ),
                            Expanded(
                              flex: 2,
                              child: CryButton(
                                label: '清除',
                                onPressed: () {
                                  saleBidProject.publicitydate = null;
                                  setState(() {});
                                },
                                iconData: Icons.cancel,
                              ),
                            )
                          ],
                        ))
            ],
          ),
          Row(
            children: [
              Expanded(
                  child: widget.isView
                      ? CryInput(
                          label: '交货日期',
                          enable: false,
                          value: saleBidProject.deliverydate,
                        )
                      : Row(
                          children: [
                            Expanded(
                              flex: 3,
                              child: CrySelectDate(
                                context,
                                label: '交货日期',
                                value: saleBidProject.deliverydate,
                                onDateChange: (v) {
                                  formKey.currentState?.save();
                                  saleBidProject.deliverydate = v;
                                  setState(() {});
                                },
                                onSaved: (v) {
                                  saleBidProject.deliverydate = v;
                                },
                              ),
                            ),
                            Expanded(
                              flex: 2,
                              child: CryButton(
                                label: '清除',
                                onPressed: () {
                                  saleBidProject.deliverydate = null;
                                  setState(() {});
                                },
                                iconData: Icons.cancel,
                              ),
                            )
                          ],
                        )),
              //num
              Expanded(
                child: CryInputNum(
                  label: '标书费(元)',
                  enable: !widget.isView,
                  value: saleBidProject.tenderfee,
                  onSaved: (v) {
                    saleBidProject.tenderfee = v;
                  },
                ),
              ),
              //num
              Expanded(
                child: CryInputNum(
                  label: '投标保证金(元)',
                  enable: !widget.isView,
                  value: saleBidProject.bidfree,
                  onSaved: (v) {
                    saleBidProject.bidfree = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              //num
              Expanded(
                child: CryInputNum(
                  label: '样品检测费(元)',
                  enable: !widget.isView,
                  value: saleBidProject.checkfee,
                  onSaved: (v) {
                    saleBidProject.checkfee = v;
                  },
                ),
              ),
              // %
              Expanded(
                child: CryInput(
                  label: '招标代理服务费',
                  enable: !widget.isView,
                  value: saleBidProject.agencyservicefee,
                  onSaved: (v) {
                    saleBidProject.agencyservicefee = v;
                  },
                ),
              ),
              // %
              Expanded(
                child: CryInput(
                  label: '履约保证金',
                  enable: !widget.isView,
                  value: saleBidProject.performancebond,
                  onSaved: (v) {
                    saleBidProject.performancebond = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '评标办法',
                  enable: !widget.isView,
                  value: saleBidProject.bidmethod,
                  onSaved: (v) {
                    saleBidProject.bidmethod = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '价格评标',
                  enable: !widget.isView,
                  value: saleBidProject.priceevaluation,
                  onSaved: (v) {
                    saleBidProject.priceevaluation = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '招标方联系人（商务）',
                  enable: !widget.isView,
                  value: saleBidProject.businesscontacts,
                  onSaved: (v) {
                    saleBidProject.businesscontacts = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '招标方联系方式（商务）',
                  enable: !widget.isView,
                  value: saleBidProject.businesscontactsnumber,
                  onSaved: (v) {
                    saleBidProject.businesscontactsnumber = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '招标方联系人（技术）',
                  enable: !widget.isView,
                  value: saleBidProject.technologycontacts,
                  onSaved: (v) {
                    saleBidProject.technologycontacts = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '招标方联系方式（技术）',
                  enable: !widget.isView,
                  value: saleBidProject.technologycontactsnumber,
                  onSaved: (v) {
                    saleBidProject.technologycontactsnumber = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '有无二次议价机会',
                        enable: false,
                        value: saleBidProject.issecondbargaining == '0'
                            ? '无'
                            : saleBidProject.issecondbargaining == '1'
                                ? '有'
                                : "",
                      )
                    : CrySelect(
                        label: '有无二次议价机会',
                        dataList: issecondbargainingList,
                        value: saleBidProject.issecondbargaining,
                        onSaved: (v) => {saleBidProject.issecondbargaining = v},
                      ),
              ),
              Expanded(
                child: CryInput(
                  label: '利润',
                  enable: !widget.isView,
                  value: saleBidProject.profit,
                  onSaved: (v) {
                    saleBidProject.profit = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '资质文件',
                  enable: !widget.isView,
                  value: saleBidProject.qualificationdocuments,
                  onSaved: (v) {
                    saleBidProject.qualificationdocuments = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '样品要求',
                  enable: !widget.isView,
                  value: saleBidProject.samplerequirements,
                  onSaved: (v) {
                    saleBidProject.samplerequirements = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '品牌专利要求',
                  enable: !widget.isView,
                  value: saleBidProject.brandpatentrequirements,
                  onSaved: (v) {
                    saleBidProject.brandpatentrequirements = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '环保要求',
                  enable: !widget.isView,
                  value: saleBidProject.environmentalrequirements,
                  onSaved: (v) {
                    saleBidProject.environmentalrequirements = v;
                  },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '包装要求',
                  enable: !widget.isView,
                  value: saleBidProject.packagingrequirements,
                  onSaved: (v) {
                    saleBidProject.packagingrequirements = v;
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '制标人',
                  enable: !widget.isView,
                  value: saleBidProject.bidmaker,
                  onSaved: (v) {
                    saleBidProject.bidmaker = v;
                  },
                ),
              ),
              Expanded(
                child: widget.isView
                    ? CryInput(
                        label: '投标结果',
                        enable: false,
                        value: saleBidProject.bidresults == '0'
                            ? '未中标'
                            : saleBidProject.bidresults == '1'
                                ? '中标'
                                : "",
                      )
                    : CrySelect(
                        label: '投标结果',
                        dataList: bidresultsList,
                        value: saleBidProject.bidresults,
                        onSaved: (v) => {saleBidProject.bidresults = v},
                      ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '价格判定',
                  enable: !widget.isView,
                  value: saleBidProject.pricedetermination,
                  onSaved: (v) {
                    saleBidProject.pricedetermination = v;
                  },
                ),
              ),
              //num
              Expanded(
                child: CryInputNum(
                  label: '报价准确率',
                  enable: !widget.isView,
                  value: saleBidProject.quotationaccuracy,
                  onSaved: (v) {
                    saleBidProject.quotationaccuracy = v;
                  },
                  // validator: (v) {
                  //   return v!.isEmpty
                  //       ? S.of(context).required
                  //       : v == '0'
                  //           ? '报价准确率不能为0'
                  //           : int.parse(v) > 100
                  //               ? '报价准确率小于等于100'
                  //               : null;
                  // },
                ),
              ),
              //num
              Expanded(
                child: CryInputNum(
                  label: '利润率',
                  enable: !widget.isView,
                  value: saleBidProject.profitmargin,
                  onSaved: (v) {
                    saleBidProject.profitmargin = v;
                  },
                  // validator: (v) {
                  //   return v!.isEmpty
                  //       ? S.of(context).required
                  //       : v == '0'
                  //           ? '利润率不能为0'
                  //           : int.parse(v) > 100
                  //               ? '利润率小于等于100'
                  //               : null;
                  // },
                ),
              )
            ],
          ),
          Row(
            children: [
              Expanded(
                child: CryInput(
                  label: '报价单',
                  enable: !widget.isView,
                  value: saleBidProject.formNo,
                  onSaved: (v) {
                    saleBidProject.formNo = v;
                  },
                  onTap: () {
                    _selectForm();
                  },
                ),
              ),
              Expanded(
                child: CryInput(
                  label: '市场和项目情况介绍及客户基础技术要求',
                  enable: !widget.isView,
                  value: saleBidProject.projectintroduction,
                  onSaved: (v) {
                    saleBidProject.projectintroduction = v;
                  },
                ),
              ),
            ],
          ),
        ],
      ),
    );
    var buttonBar = ButtonBar(
      alignment: MainAxisAlignment.center,
      children: <Widget>[
        widget.isView
            ? Text('')
            : CryButton(
                label: S.of(context).save,
                onPressed: () {
                  FormState form = formKey.currentState!;
                  if (!form.validate()) {
                    return;
                  }
                  form.save();
                  SaleBidProjectOdooApi.saveOrUpdate(saleBidProject.toOdooMap())
                      .then((ResponseBodyApi res) {
                    if (!res.success!) {
                      return;
                    }
                    Navigator.pop(context, true);
                    CryUtils.message(S.of(context).saved);
                  });
                },
                iconData: Icons.save,
              ),
        CryButton(
          label: S.of(context).cancel,
          onPressed: () {
            Navigator.pop(context);
          },
          iconData: Icons.cancel,
        )
      ],
    );
    var result = Scaffold(
      appBar: AppBar(
        title: Text(widget.isView
            ? "查看"
            : this.isAdd!
                ? S.of(context).add
                : S.of(context).modify),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [form],
        ),
      ),
      bottomNavigationBar: buttonBar,
    );
    return SizedBox(
      // width: 650,
      height: 650,
      child: result,
    );
    // return result;
  }
}
